<?php
namespace app\admin\controller;
use think\Db;
class Setup extends Base{
    public function index(){
		$res=Db::name('setup')->where('id',1)->find();
		$this->assign('data',$res);
        return $this->fetch();
    }
    public function setup_add(){
    	if(request()->isPost()){
			$param = input('post.');
			$data['protocol']=html_entity_decode($param['protocol']);
            $data['credit_agree']=html_entity_decode($param['credit_agree']);
			$res=Db::name('setup')->where('id',1)->find();
			if ($res) {
        		Db::name('setup')->where(array('id'=>1))->update($data);
			}else{
				Db::name('setup')->insert($data);
			}
        	//return $this->fetch('index');
        	$this->redirect('index');
    	}
    }
}